home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98b.txt
/
000120_icon-group-sender _Tue Jun 30 08:00:45 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
4KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id IAA28503
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 30 Jun 1998 08:00:45 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA00768; Tue, 30 Jun 1998 08:00:32 -0700
Date: Tue, 30 Jun 1998 08:23:23 -0500 (CDT)
From: Chris Tenaglia <cdt@post.its.mcw.edu>
To: icon-group@optima.CS.Arizona.EDU
Subject: sample CGI
Message-Id: <Pine.SOL.3.96.980630081906.29720A-100000@post.its.mcw.edu>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 2869
This CGI stuff is a snap once you get the hang of it. Here's a
sample. This is a CGI to return the time remainting till the
turn of the century. It also records visits in a logfile.
I was able to run it at http://www.mcw.edu/cgi-bin/bioet/cdown
where it will be for a few days. As usual the file permissions
are the most sensitive issue. Here's the source;
_______________________________________________________________
#
# file : cdown.icn
# desc : This program returns countdown information till
# the turn of the century
# use : to be called by a cgi script in a web page : .../cgi-bin/cdown
# note : 730 days from 1/1/1998 to 1/1/2000
#
# update by what
# 29-jun-1998 tenaglia initial write
#
procedure main()
write("content-type: text/html")
write()
write("<HTML>")
write("<HEAD>")
write("<TITLE>")
write("Century Countdown")
write("</TITLE>")
write("</HEAD>")
write("<BODY BGCOLOR=#ffffff>")
write("<CENTER><FONT COLOR=#c00000>")
write("<H1>Century CountDown !</H1>")
write("<P>")
write("<TABLE border=10>")
write("<TH><H3><FONT COLOR=#800080>")
write("Today is ",&dateline,"</TH>")
#
# gather the time fields from the current moment
#
date := &date
time := &clock
delta:= [0,31,59,90,120,151,181,212,243,273,304,334,365]
year := parse(date,'/')[1]
month:= parse(date,'/')[2]
day := parse(date,'/')[3]
hour := parse(time,':')[1]
min := parse(time,':')[2]
sec := parse(time,':')[3]
#
# calculate the time left until 1/1/2000
#
diff := (year - 1998) * 365 + delta[month] + day
remains := 730 - diff
part1 := 24 - hour
part2 := 60 - min
part3 := 60 - sec
write("<TR><TD><FONT COLOR=#800080><CENTER>There are ",remains," days,</CENTER></TD></TR>")
write("<TR><TD><FONT COLOR=#800080><CENTER>And ",part1," hours,</CENTER></TD></TR>",
"<TR><TD><FONT COLOR=#800080><CENTER>",part2," minutes,<CENTER></TD></TR>",
"<TR><TD><FONT COLOR=#800080><CENTER>",part3," seconds until 2000 A.D.</CENTER></TD></TR>")
write("</FONT></TABLE>")
write("<P></FONT>")
write("</BODY>")
write("</HTML>")
#
# record visits
#
computer:= getenv("REMOTE_ADDR")
logfile := open("cdown.log","a")
write(logfile,"CDOWN accessed ",&dateline," from ",computer)
close(logfile)
end
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
_______________________________________________________________
Chris Tenaglia (system manager) | The future foretold,
Medical College of Wisconsin | The past explained,
8701 W. Watertown Plank Rd. | The present largely appologized for.
Milwaukee, WI 53226 (414)456-8765 | Organon to the Doctor